import React, { useReducer } from 'react';
import reducer from './reducer';
const UseReducerView = () => {
  const [state, dispatch] = useReducer(reducer, { count: 0, age: 11 });

  return (
    <div>
      <hr />
      <h1> 子组件：</h1>
      <div>
        <b>count: {state.count}</b>
      </div>
      <div>
        <button type="button" onClick={() => {
          dispatch({ type: 'increment', payload: 10 })
        }}>increment</button>
        <button type="button" onClick={() => {
          dispatch({ type: 'decrement' })
        }}>decrement</button>

      </div>
    </div>
  );
}

export default UseReducerView;
